home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-04-28 | 6.3 KB | 186 lines | [TEXT/MPS ] |
- {
- File: Translation.p
-
- Contains: Pascal Interface to the Translation Manager
-
- Copyright: © 1990-1993 by Apple Computer, Inc., all rights reserved.
- }
-
- {$IFC UNDEFINED UsingIncludes}
- {$SETC UsingIncludes := 0}
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- UNIT Translation;
- INTERFACE
- {$ENDC}
-
- {$IFC UNDEFINED UsingTranslation}
- {$SETC UsingTranslation := 1}
-
- {$I+}
- {$SETC TranslationIncludes := UsingIncludes}
- {$SETC UsingIncludes := 1}
- {$IFC UNDEFINED UsingTypes}
- {$I $$Shell(PInterfaces)Types.p}
- {$ENDC}
- {$IFC UNDEFINED UsingFiles}
- {$I $$Shell(PInterfaces)Files.p}
- {$ENDC}
- {$IFC UNDEFINED UsingMemory}
- {$I $$Shell(PInterfaces)Memory.p}
- {$ENDC}
- {$IFC UNDEFINED UsingStandardFile}
- {$I $$Shell(PInterfaces)StandardFile.p}
- {$ENDC}
- {$IFC UNDEFINED UsingTranslationExtensions}
- {$I TranslationExtensions.p}
- {$ENDC}
-
- {$SETC UsingIncludes := TranslationIncludes}
-
-
- CONST
- gestaltTranslationAttr = 'xlat'; { ••• move into GestaltEqu.p }
- gestaltTranslationMgrExists = 0; { ••• move into GestaltEqu.p }
- gestaltTranslationMgrHintOrder = 1; { True if hint order reversal fix in effect }
-
- { gestaltStandardFileAttr = 'stdf'; }
- { gestaltStandardFile58 = 0; }
- gestaltStandardFileTranslationAware = 1; { ••• move into GestaltEqu.p }
- gestaltStandardFileHasColorIcons = 2; { ••• move into GestaltEqu.p }
-
- { gestaltEditionMgrAttr = 'edtn'; }
- { gestaltEditionMgrPresent = 0; }
- gestaltEditionMgrTranslationAware = 1; { ••• move into GestaltEqu.p }
-
- gestaltScrapMgrAttr = 'scra';
- gestaltScrapMgrTranslationAware = 0; { ••• move into GestaltEqu.p }
-
-
- noTranslationPathErr = -3030; { ••• move into Errors.p }
- badTranslationSpecErr = -3031; { ••• move into Errors.p }
- noPrefAppErr = -3032; { ••• move into Errors.p }
-
- { invalidTranslationPathErr = -3025; ••• move into Errors.p (TranslationExtensions.p }
- { couldNotParseSourceFileErr = -3026; ••• move into Errors.p (TranslationExtensions.p }
-
-
- TYPE
- { block of data that describes how to translate }
- FileTranslationSpec = ARRAY [1..12] OF LONGINT;
-
- { enumerated types on how a document can be opened }
- DocOpenMethod = ( domCannot, domNative, domTranslateFirst, domWildcard );
-
- { Zero terminated array of file types }
- TypesBlock = ARRAY [0..63] OF FileType;
- TypesBlockPtr = ^TypesBlock;
-
- FileTypePtr = ^FileType;
-
-
- {
- //////////////////////////////////////////////////////////////////////////////////////////////
- //
- // GetFileTypesThatAppCanNativelyOpen
- //
- // This routine returns a list of all FileTypes that an application can open by itself
- //
- // Enter: appVRefNumHint volume where application resides (can be wrong, and if is, will be used as a starting point)
- // appSignature signature (creator) of application
- // nativeTypes pointer to a buffer to be filled with up to 64 FileTypes
- //
- // Exit: nativeTypes zero terminated array of FileTypes that can be opened by app
- //
- }
- FUNCTION GetFileTypesThatAppCanNativelyOpen(appVRefNumHint : INTEGER;
- appSignature : OSType;
- VAR nativeTypes : TypesBlock) :OSErr;
- INLINE $701C, $ABFC;
-
-
- {
- //////////////////////////////////////////////////////////////////////////////////////////////
- //
- // ExtendFileTypeList
- //
- // This routine makes a new list of file types that can be translated into a type in the given list
- // Used by StandardFile
- //
- // Enter: originalTypeList pointer to list of file types that can be opened
- // numberOriginalTypes number of file types in orgTypeList
- // extendedTypeList pointer to a buffer to be filled with file types
- // numberExtendedTypes max number of file types that can be put in extendedTypeList
- //
- // Exit: extendedTypeList buffer filled in with file types that can be translated
- // numberExtendedTypes number of file types put in extendedTypeList
- //
- }
- FUNCTION ExtendFileTypeList( originalTypeList : FileTypePtr;
- numberOriginalTypes : INTEGER;
- extendedTypeList : FileTypePtr;
- VAR numberExtendedTypes : INTEGER) : OSErr;
- INLINE $7009, $ABFC;
-
-
- {
- ////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // This routine checks if a file can be opened by a particular application.
- // If so, it returns if it needs to be translated first, and if so then how.
- // The FileTypes that the app can open are specified by nativelyOpenableTypes,
- // or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
- //
- // Enter: targetDocument document to check if it can be opened
- // appVRefNumHint vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
- // appSignature signature (creator) of application to open doc
- // nativeTypes zero terminated list of FileTypes app can open natively, or NULL to use default list
- // onlyNative whether to consider if document can be translated before opening
- // howToOpen pointer to buffer in which to put how the document can be opened
- // howToTranslate pointer to buffer in which to put a FileTranslationSpec record
- //
- // Exit: howToOpen whether file needs to be translated to be read
- // howToTranslate if file can be translated, buffer filled in with how to translate
- // returns noErr, noPrefAppErr
- //
- }
- FUNCTION CanDocBeOpened( targetDocument : FSSpec;
- appVRefNumHint : INTEGER;
- appSignature : OSType;
- nativeTypes : TypesBlockPtr;
- onlyNative : Boolean;
- VAR howToOpen : DocOpenMethod;
- VAR howToTranslate : FileTranslationSpec) : OSErr;
- INLINE $701E, $ABFC;
-
-
- {
- //////////////////////////////////////////////////////////////////////////////////////////////
- //
- // TranslateFile
- //
- // This routine reads a file of one format and writes it to another file in another format.
- // The information on how to translated is generated by the routine CanDocBeOpened.
- // TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.
- // The destination file must not exist. It is created by this routine.
- //
- // Enter: sourceDocument input file to translate
- // destinationDocument output file of translation
- // howToTranslate pointer to info on how to translate
- // Exit: returns noErr, badTranslationSpecErr
- //
- }
- FUNCTION TranslateFile(sourceDocument : FSSpec;
- destinationDocument : FSSpec;
- howToTranslate : FileTranslationSpec) : OSErr;
- INLINE $700C, $ABFC;
-
-
-
- {$ENDC} { UsingTranslation}
-
- {$IFC NOT UsingIncludes}
- END.
- {$ENDC}
-